﻿using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace game.LoadScene
{
    public class SceneLoadingMask : MonoBehaviour
    {

        public CanvasGroup cg;
        public float duration = 0.54f;
        public void ShowMask(System.Action _fin)
        {
            if (!gameObject.activeInHierarchy)
            {
                gameObject.SetActive(true);
            }
            cg.alpha = 0f;
            cg.DOFade(1f, duration).OnComplete(() =>
            {
                if (_fin != null)
                    _fin();
            }
            );
        }

        public void HideMask(System.Action _fin)
        {
            if (!gameObject.activeInHierarchy)
            {
                gameObject.SetActive(true);
            }
            cg.alpha = 1f;
            cg.DOFade(0f, duration).OnComplete(() =>
            {
                if (_fin != null)
                    _fin();

                gameObject.SetActive(false);
            }
            );
        }
    }

}
